package com.itelite.service.impl;

/**
 * @author 沈洋 邮箱:1845973183@qq.com
 * @create 2021/8/29-16:28
 **/

import com.itelite.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 继承Application接口后项目启动时会按照执行顺序执行run方法
 * 通过设置Order的value来指定执行的顺序
 */
@Slf4j
@Component
@Order(value = 1)
public class StartServiceImpl implements ApplicationRunner {
    @Autowired
    private RedisService redisService;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        redisService.removeAllValue();
        log.info("清空Redis中缓存");
    }
}